//
//  DeviceUUID.m
//  JionMe
//
//  Created by grx on 2017/2/17.
//  Copyright © 2017年 grx. All rights reserved.
//

#import "DeviceUUID.h"
#import "KeyChainStore.h" 

@implementation DeviceUUID

+(NSString *)getUUID
{
    return [DeviceUUID getUUIDWithKey:@"com.rrymbf"];
}

+ (NSString *)getUUIDWithKey:(NSString *)key
{
    NSString *bundleId = key;
    NSString * strUUID = (NSString *)[KeyChainStore load:bundleId];
    if ([strUUID isEqualToString:@""] || !strUUID)
    {
        CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
        strUUID = (NSString *)CFBridgingRelease(CFUUIDCreateString (kCFAllocatorDefault,uuidRef));
         CFRelease(uuidRef);
        [KeyChainStore save:bundleId data:strUUID];
    }
    return strUUID;
}

@end
